home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1993 / Internet Info CD-ROM (Walnut Creek) (1993).iso / networking / terms / tipx / tip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-11  |  7.9 KB  |  289 lines

  1. /*
  2.  * Copyright (c) 1983 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  *
  17.  *    @(#)tip.h    5.4 (Berkeley) 9/2/88
  18.  */
  19.  
  20. /*
  21.  * tip - terminal interface program
  22.  */
  23.  
  24. #include <sys/types.h>
  25. #include <sys/file.h>
  26.  
  27. #include <sgtty.h>
  28. #include <signal.h>
  29. #include <stdio.h>
  30. #include <pwd.h>
  31. #include <ctype.h>
  32. #include <setjmp.h>
  33. #include <errno.h>
  34. #include <netdb.h>
  35. #include <string.h>
  36.  
  37. #ifndef sun        /* wht@n4hgf */
  38. #define strchr index    /* wht@n4hgf */
  39. #endif            /* wht@n4hgf */
  40.  
  41. #if    defined(SUNOS4) || defined(__ANSI__) || defined(sparc)
  42. typedef void sigfunc_t;
  43. #else
  44. typedef int sigfunc_t;
  45. #endif
  46.  
  47. /*
  48.  * Remote host attributes
  49.  */
  50. char    *DV;            /* UNIX device(s) to open */
  51. char    *EL;            /* chars marking an EOL */
  52. char    *CM;            /* initial connection message */
  53. char    *IE;            /* EOT to expect on input */
  54. char    *OE;            /* EOT to send to complete FT */
  55. char    *CU;            /* call unit if making a phone call */
  56. char    *AT;            /* acu type */
  57. char    *PN;            /* phone number(s) */
  58. char    *DI;            /* disconnect string */
  59. char    *PA;            /* parity to be generated */
  60.  
  61. char    *PH;            /* phone number file */
  62. char    *RM;            /* remote file name */
  63. char    *HO;            /* host name */
  64.  
  65. char    *SA;            /* local slip address */
  66. char    *DA;            /* destination slip address */
  67. char    *SM;            /* netmask for slip */
  68. char    *ST;            /* slip type */
  69. char    *LS;            /* login script file */
  70.  
  71. int    BR;            /* line speed for conversation */
  72. int    FS;            /* frame size for transfers */
  73.  
  74. char    DU;            /* this host is dialed up */
  75. char    HW;            /* this device is hardwired, see hunt.c */
  76. char    *ES;            /* escape character */
  77. char    *EX;            /* exceptions */
  78. char    *FO;            /* force (literal next) char*/
  79. char    *RC;            /* raise character */
  80. char    *RE;            /* script record file */
  81. char    *PR;            /* remote prompt */
  82. int    DL;            /* line delay for file transfers to remote */
  83. int    CL;            /* char delay for file transfers to remote */
  84. int    ET;            /* echocheck timeout */
  85. char    HD;            /* this host is half duplex - do local echo */
  86.  
  87. /*
  88.  * String value table
  89.  */
  90. typedef
  91.     struct {
  92.         char    *v_name;    /* whose name is it */
  93.         char    v_type;        /* for interpreting set's */
  94.         char    v_access;    /* protection of touchy ones */
  95.         char    *v_abrev;    /* possible abreviation */
  96.         char    *v_value;    /* casted to a union later */
  97.     }
  98.     value_t;
  99.  
  100. #define STRING    01        /* string valued */
  101. #define BOOL    02        /* true-false value */
  102. #define NUMBER    04        /* numeric value */
  103. #define CHAR    010        /* character value */
  104.  
  105. #define WRITE    01        /* write access to variable */
  106. #define    READ    02        /* read access */
  107.  
  108. #define CHANGED    01        /* low bit is used to show modification */
  109. #define PUBLIC    1        /* public access rights */
  110. #define PRIVATE    03        /* private to definer */
  111. #define ROOT    05        /* root defined */
  112.  
  113. #define    TRUE    1
  114. #define FALSE    0
  115.  
  116. #define ENVIRON    020        /* initialize out of the environment */
  117. #define IREMOTE    040        /* initialize out of remote structure */
  118. #define INIT    0100        /* static data space used for initialization */
  119. #define TMASK    017
  120.  
  121. /*
  122.  * Definition of ACU line description
  123.  */
  124. typedef
  125.     struct {
  126.         char    *acu_name;
  127.         int    (*acu_dialer)();
  128.         int    (*acu_disconnect)();
  129.         int    (*acu_abort)();
  130.     }
  131.     acu_t;
  132.  
  133. #define    equal(a, b)    (strcmp(a,b)==0)/* A nice function to string compare */
  134.  
  135. /*
  136.  * variable manipulation stuff --
  137.  *   if we defined the value entry in value_t, then we couldn't
  138.  *   initialize it in vars.c, so we cast it as needed to keep lint
  139.  *   happy.
  140.  */
  141. typedef
  142.     union {
  143.         int    zz_number;
  144.         short    zz_boolean[2];
  145.         char    zz_character[4];
  146.         int    *zz_address;
  147.     }
  148.     zzhack;
  149.  
  150. #define value(v)    vtable[v].v_value
  151.  
  152. #define number(v)    ((((zzhack *)(&(v))))->zz_number)
  153. #ifdef vax
  154. #define boolean(v)    ((((zzhack *)(&(v))))->zz_boolean[0])
  155. #define character(v)    ((((zzhack *)(&(v))))->zz_character[0])
  156. #else
  157. #define boolean(v)    ((((zzhack *)(&(v))))->zz_boolean[1])
  158. #define character(v)    ((((zzhack *)(&(v))))->zz_character[3])
  159. #endif
  160. #define address(v)    ((((zzhack *)(&(v))))->zz_address)
  161.  
  162. /*
  163.  * Escape command table definitions --
  164.  *   lookup in this table is performed when ``escapec'' is recognized
  165.  *   at the begining of a line (as defined by the eolmarks variable).
  166. */
  167.  
  168. typedef
  169.     struct {
  170.         char    e_char;        /* char to match on */
  171.         char    e_flags;    /* experimental, priviledged */
  172.         char    *e_help;    /* help string */
  173.         int     (*e_func)();    /* command */
  174.     }
  175.     esctable_t;
  176.  
  177. #define NORM    00        /* normal protection, execute anyone */
  178. #define EXP    01        /* experimental, mark it with a `*' on help */
  179. #define PRIV    02        /* priviledged, root execute only */
  180.  
  181. extern int    vflag;        /* verbose during reading of .tiprc file */
  182. extern value_t    vtable[];    /* variable table */
  183.  
  184. #ifndef ACULOG
  185. #define logent(a, b, c, d)
  186. #define loginit()
  187. #endif
  188.  
  189. /*
  190.  * Definition of indices into variable table so
  191.  *  value(DEFINE) turns into a static address.
  192.  */
  193.  
  194. #define BEAUTIFY    0
  195. #define BAUDRATE    1
  196. #define DIALTIMEOUT    2
  197. #define EOFREAD        3
  198. #define EOFWRITE    4
  199. #define EOL        5
  200. #define ESCAPE        6
  201. #define EXCEPTIONS    7
  202. #define FORCE        8
  203. #define FRAMESIZE    9
  204. #define HOST        10
  205. #define LOG        11
  206. #define PHONES        12
  207. #define PROMPT        13
  208. #define RAISE        14
  209. #define RAISECHAR    15
  210. #define RECORD        16
  211. #define REMOTE        17
  212. #define SCRIPT        18
  213. #define TABEXPAND    19
  214. #define VERBOSE        20
  215. #define SHELL        21
  216. #define HOME        22
  217. #define ECHOCHECK    23
  218. #define DISCONNECT    24
  219. #define TAND        25
  220. #define LDELAY        26
  221. #define CDELAY        27
  222. #define ETIMEOUT    28
  223. #define RAWFTP        29
  224. #define HALFDUPLEX    30
  225. #define    LECHO        31
  226. #define    PARITY        32
  227. #define    SLIPADDR    33
  228. #define SLIPDSTADDR    34
  229. #define    SLIPMASK    35
  230. #define    SLIPTYPE    36
  231. #define LOGINSCRIPT    37
  232. #define    SETROUTE    38
  233. #define LINESYNC        39
  234. #define DTRHUP        40
  235.  
  236. #define NOVAL    ((value_t *)NULL)
  237. #define NOACU    ((acu_t *)NULL)
  238. #define NOSTR    ((char *)NULL)
  239. #define NOFILE    ((FILE *)NULL)
  240. #define NOPWD    ((struct passwd *)0)
  241.  
  242. struct sgttyb    arg;        /* current mode of local terminal */
  243. struct sgttyb    defarg;        /* initial mode of local terminal */
  244. struct tchars    tchars;        /* current state of terminal */
  245. struct tchars    defchars;    /* initial state of terminal */
  246. struct ltchars    ltchars;    /* current local characters of terminal */
  247. struct ltchars    deflchars;    /* initial local characters of terminal */
  248.  
  249. FILE    *fscript;        /* FILE for scripting */
  250.  
  251. int    fildes[2];        /* file transfer synchronization channel */
  252. int    repdes[2];        /* read process sychronization channel */
  253. int    FD;            /* open file descriptor to remote host */
  254. int    AC;            /* open file descriptor to dialer (v831 only) */
  255. int    vflag;            /* print .tiprc initialization sequence */
  256. int    sfd;            /* for ~< operation */
  257. int    pid;            /* pid of tipout */
  258. uid_t    uid, euid;        /* real and effective user id's */
  259. gid_t    gid, egid;        /* real and effective group id's */
  260. int    stop;            /* stop transfer session flag */
  261. int    quit;            /* same; but on other end */
  262. int    stoprompt;        /* for interrupting a prompt session */
  263. int    timedout;        /* ~> transfer timedout */
  264. int    cumode;            /* simulating the "cu" program */
  265. int    slip;            /* bring up SLIP on the line */
  266.  
  267. char    fname[80];        /* file name buffer for ~< */
  268. char    copyname[80];        /* file name buffer for ~> */
  269. char    ccc;            /* synchronization character */
  270. char    uucplock[];        /* name of lock file for uucp's */
  271.  
  272. int    odisc;                /* initial tty line discipline */
  273. extern    int disc;            /* current tty discpline */
  274.  
  275. extern    char *ctrl();
  276. extern    char *ctime();
  277. extern    long time();
  278. extern    struct passwd *getpwuid();
  279. extern    char *getlogin();
  280. extern    char *vinterp();
  281. extern    char *getenv();
  282. extern    char *rindex();
  283. extern    char *index();
  284. extern    char *malloc();
  285. extern    char *lconnect();
  286.  
  287. #undef CTRL
  288. #define    CTRL(c)    ((c)&037)
  289.